using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using NUnit.Framework;
using Wax;

namespace WaxLibTest
{
    /// <summary>
    /// Test the behavior of the <see cref="InvalidFindMethodException"/> class.
    /// </summary>
    [TestFixture]
    public class InvalidFindMethodExceptionTest
    {
        [Test]
        public void Serialize()
        {
            string methodName = "UsingBiik";
            InvalidFindMethodException invalidFindMethodException = new InvalidFindMethodException(methodName);

            using (Stream memory = new MemoryStream())
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(memory, invalidFindMethodException);
                memory.Position = 0; // Reset stream position
                invalidFindMethodException = (InvalidFindMethodException)formatter.Deserialize(memory);
            }

            Assert.IsNotNull(invalidFindMethodException, "InvalidCommandException object was not serialized properly.");
            Assert.AreEqual(methodName, invalidFindMethodException.InvalidMethodName);
        }
    }
}